package com.nl.test;

public class StockMaxProfit {
	
	public static void main(String[] args) {
		int [] prices = new int[]{10,21,42,12,11,332,22};
		int low = prices[0];
		int maxProfit = 0;
		for(int i=1;i<prices.length;i++){
			int profit = prices[i] -low;
			if(profit>maxProfit){
				maxProfit = profit;
			}
			if(prices[i]<low){
				low = prices[i];
			}
		}
		System.out.println(maxProfit);
	}

}
